#pragma once

#include <QDialog>
#include "ui_StepSettingDialog.h"
#include "PackDefine.h"
#include "BTEProject.h"

class StepTableHelper : public QObject
{
    Q_OBJECT

public:
	void init(QTableWidget *table);
	void updateTable(const BTEStepInfo &stepInfo);

	QTableWidget *tableWidget;
};

class StepSettingDialog : public QDialog
{
	Q_OBJECT

public:
	StepSettingDialog(QWidget *parent = Q_NULLPTR);
	~StepSettingDialog();

	QString DeviceString;
	int itemIndex;
	BTEStepInfo stepInfo;

protected slots:
	void on_btnAdd_clicked();
	void on_btnDel_clicked();
	void on_btnEdit_clicked();
	void on_btnUp_clicked();
	void on_btnDown_clicked();
	void on_btnInit_clicked();

	void on_btnSave_clicked();
	void on_btnOpen_clicked();
	void on_btnBack_clicked();
	void on_btnSet_clicked();

	void on_btnOk_clicked();
	void on_btnCancel_clicked();

	void on_tableWidget_itemPressed(QTableWidgetItem *item);	
	void on_tableWidget_itemDoubleClicked(QTableWidgetItem *item);

private:
	virtual void showEvent(QShowEvent *event) override;		
	void initStep();
	bool uiToStep();
	void updateTable();		
		
	bool checkParam(QCheckBox *box, QLineEdit *edit, double &var,double low,double upper,bool must = true);
	void stepParamToUi(const stru_BTS_CMD_SET_STEP76_Ex::StepInfo &step, int param_index, QCheckBox *box, QLineEdit *edit);
	bool checkStep();
	
	StepTableHelper m_tableHelper;
	Ui::StepSettingDialog ui;
};
